 
/* PatchInspector.m	Peter Wickersham 
 * 
 * Methods for PatchInspector class.
 *
 */
 
#import "../Stone3DAPI/Stone3D.h"

#import "PatchInspector.h"
#import "Patch.h"

@implementation PatchInspector

// loadShape:inView is a method declared in Inspector3D to provide the 
// inspector with a place to initialize its interface objects and any
// other internal initialization that it might need to do.  Here, I set
// my interface objects according to how Patch wants them to be defaulted.
- loadShape:(Shape *)shape inView:(Camera *)camera
{
    // Perform superclass method first
    [super loadShape:shape inView:camera];
    if (shape) {
	if ([shape isKindOf:[Patch class]]) {
	    // Set the states of the interface objects by getting the
	    // info from Patch.
	    [pointsVisibleSwitch setState:
				    [(Patch *)shape controlVisible]];
	    [hullVisibleSwitch setState:
				    [(Patch *)shape hullVisible]];
	    setTitle(uBasisButton,[(Patch *)shape uBasis]);
	    setTitle(vBasisButton,[(Patch *)shape vBasis]);
	}
    }
    return self;
}

// Theses methods are for changing certain characteristics about the 
// currently selected shape. Using the selectedShape method defined 
// in PatchInspector's superclasses lets us get the id of the selected Patch.
// Then we use the inherited method displayChanges to redraw the shapes.

- changePointsVisible:sender
{   
    Shape *shape = [self selectedShape];
    if (shape && [shape isKindOf:[Patch class]]) {
	[(Patch *)shape setControlVisible:[sender state]];
	[self displayChanges];
    }

    return self;
}

- changeHullVisible:sender
{
    Shape *shape = [self selectedShape];
    if (shape && [shape isKindOf:[Patch class]]) {
	[(Patch *)shape setHullVisible:[sender state]];
	[self displayChanges];
    }

    return self;
}
   

- setUBasis:sender
{
    Shape *shape = [self selectedShape];
    if (shape && [shape isKindOf:[Patch class]]) {
	[(Patch *)shape setUBasis:[sender selectedTag]];
	[self displayChanges];
    }
    return self;
}

- setVBasis:sender
{
    Shape *shape = [self selectedShape];
    if (shape && [shape isKindOf:[Patch class]]) {
	[(Patch *)shape setVBasis:[sender selectedTag]];
	[self displayChanges];
    }
    return self;
}

@end